home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Games / Starter / JST / Developer / sources / src / loaders / Xout / xouthd.asm < prev   
Encoding:
Assembly Source File  |  1999-12-03  |  5.1 KB  |  344 lines

  1. ; *** X-Out Hard Disk Loader BETA
  2. ; *** Written by Jean-François Fabre
  3.  
  4.  
  5.    include  "jst.i"
  6.  
  7.    HD_PARAMS   "Xout.d",942944,2
  8.  
  9. PATCH_BLIT:MACRO
  10. PatchBlitD\1:
  11.    bsr   WaitBlit
  12.    move.w   D\1,($58,A6)
  13.    RTE
  14.    ENDM
  15.  
  16. loader:
  17.    Mac_printf  "X-Out HD Loader V1.0b"
  18.    Mac_printf  "Coded by Jean-François Fabre © 1997"
  19.  
  20.    JSRABS   LoadDisks
  21.  
  22.    moveq.l  #0,D0
  23.    move.l   #CACRF_CopyBack,D1
  24.    JSRABS   Degrade
  25.  
  26. ;  WAIT_LMB
  27.  
  28.    GO_SUPERVISOR
  29.    SAVE_OSDATA $80000
  30.  
  31.    move.w   #$2700,SR
  32.  
  33.    MOVE  #$7FFF,D0
  34.    MOVE  D0,dmacon(A6)
  35.    MOVE  D0,intena(A6)
  36.    MOVE  D0,intreq(A6)
  37.  
  38.    ; **** boot stuff and patch
  39.  
  40.    bsr   InstallBoot
  41.  
  42.    JSRGEN   FlushCachesHard   
  43.    JMP   $1D000
  44.  
  45. InstallBoot:
  46.    moveq #0,D0
  47.    lea   $1CFFE,A0
  48.    move.l   #$1750*2,D1
  49.    moveq.l  #0,D2
  50.    JSRGEN   ReadDiskPart
  51.    
  52.    ; *** first read routine
  53.  
  54.    PATCHUSRJMP $1D972,ReadRoutine
  55.  
  56.    ; *** remove gototrack 0, dskrdy code
  57.  
  58.    move.w   #$4E75,$1DA4C
  59.    move.w   #$4E75,$1DA04
  60.    move.w   #$4E75,$1DA22
  61.  
  62.    ; *** set disk change patches
  63.  
  64.    PATCHUSRJMP $1D678,SetDiskA
  65.    PATCHUSRJMP $1D6DE,SetDiskB
  66.    
  67.    ; *** remove a clearmem+disable interrupts
  68.  
  69.    move.w   #$4E75,$1D4FE
  70.  
  71.    ; *** lay a patch for intro sequence
  72.  
  73.    PATCHUSRJMP $1D06C,PatchIntro
  74.  
  75.    ; *** lay a patch for weapon choose
  76.  
  77.    PATCHUSRJMP $1D5DE,PatchWeapons
  78.    PATCHUSRJMP $1D60C,PatchWeapons
  79.  
  80.    ; *** lay a patch for game (disk 1 levels)
  81.  
  82.    PATCHUSRJMP $1D5B0,PatchGameD1
  83.  
  84.    ; *** lay a patch for game (disk 2 levels)
  85.  
  86.    PATCHUSRJMP $1D586,PatchGameD2
  87.  
  88.    ; *** lay a patch for hi-score sequence
  89.  
  90.    PATCHUSRJMP $1D4F8,PatchHiscores
  91.  
  92.    ; *** set trap handlers for blitter waits
  93.  
  94.    GETUSRADDR  PatchBlitD1
  95.    move.l   D0,$B0.W
  96.    GETUSRADDR  PatchBlitD3
  97.    move.l   D0,$B4.W
  98.    GETUSRADDR  PatchBlitD4
  99.    move.l   D0,$B8.W
  100.    GETUSRADDR  PatchBlitD6
  101.    move.l   D0,$BC.W
  102.  
  103.    rts
  104.  
  105. SetDiskA:
  106.    movem.l  D0/A0,-(sp)
  107.    moveq #0,D0
  108.    bra   SetDiskX 
  109.  
  110. SetDiskB:
  111.    movem.l  D0/A0,-(sp)
  112.    moveq #1,D0
  113.  
  114. SetDiskX:
  115.    lea   currdisk(pc),A0
  116.    move.l   D0,(A0)
  117.    JSRGEN   SetDisk
  118.    movem.l  (sp)+,D0/A0
  119.    rts
  120.  
  121.  
  122. PatchIntro:
  123.    STORE_REGS
  124.  
  125.    ; *** install quit key
  126.  
  127.    PATCHUSRJSR $21700,KbInt
  128.    move.w   #$4E71,$21706
  129.  
  130.    ; *** insert blitter waits
  131.  
  132.    move.l   #$4E4C4E71,$2110C
  133.  
  134.    lea   $21270,A0
  135.    lea   $21600,A1
  136.    bsr   InsertBlitWaits
  137.  
  138.    JSRGEN   GoECS
  139.    JSRGEN   FlushCachesHard
  140.    RESTORE_REGS
  141.    JMP   $20048
  142.  
  143.  
  144. PatchWeapons:
  145.    STORE_REGS
  146.  
  147.    ; *** install quit key
  148.  
  149.    PATCHUSRJSR $220E2,KbInt
  150.    move.w   #$4E71,$220E8
  151.  
  152.    ; *** insert blitter waits
  153.  
  154.    
  155.    move.l   #$4E4C4E71,$21C2E
  156.  
  157.    lea   $21D00,A0
  158.    lea   $22000,A1
  159.    bsr   InsertBlitWaits
  160.  
  161.    JSRGEN   FlushCachesHard
  162.    RESTORE_REGS
  163.    JMP   $20000
  164.  
  165.  
  166. ; *** the code is different given the level!!
  167.  
  168. PatchGameD1:
  169.    STORE_REGS
  170.  
  171.    ; *** install quit key
  172.  
  173.    lea   $28000,A0
  174.    lea   $29000,A1
  175.    bsr   InsertKbInt 
  176.  
  177.    ; *** insert blitter waits
  178.  
  179.    lea   $28000,A0
  180.    lea   $29000,A1
  181.    bsr   InsertBlitWaits
  182.  
  183.    lea   $28000,A0
  184.    lea   $29000,A1
  185.    bsr   InsertBlitWaitsGame
  186.  
  187.    JSRGEN   FlushCachesHard
  188.    RESTORE_REGS
  189.    JMP   $20006
  190.  
  191. ; *** the code is different given the level!!
  192.  
  193. PatchGameD2:
  194.    STORE_REGS
  195.  
  196.    ; *** install quit key
  197.  
  198.    lea   $26000,A0
  199.    lea   $28000,A1
  200.    bsr   InsertKbInt 
  201.  
  202.    ; *** insert blitter waits
  203.  
  204.    lea   $25000,A0
  205.    lea   $28000,A1
  206.    bsr   InsertBlitWaits
  207.  
  208.    lea   $25000,A0
  209.    lea   $28000,A1
  210.    bsr   InsertBlitWaitsGame
  211.  
  212.    JSRGEN   FlushCachesHard
  213.    RESTORE_REGS
  214.    JMP   $20000
  215.  
  216. PatchHiscores:
  217.    STORE_REGS
  218.  
  219.    ; *** install quit key
  220.  
  221.    PATCHUSRJSR $20C5A,KbInt
  222.    move.w   #$4E71,$20C60
  223.  
  224.    ; *** insert blitter waits
  225.  
  226.    move.l   #$4E4C4E71,$2079E
  227.  
  228.    lea   $20860,A0
  229.    lea   $20B20,A1
  230.    bsr   InsertBlitWaits
  231.  
  232.    JSRGEN   FlushCachesHard
  233.    RESTORE_REGS
  234.    JMP   $20000
  235.  
  236.    PATCH_BLIT  1
  237.    PATCH_BLIT  3
  238.    PATCH_BLIT  4
  239.    PATCH_BLIT  6
  240.  
  241. WaitBlit:
  242. wb$
  243.    btst  #6,($2,A6)
  244.    bne.b wb$
  245.    rts
  246.  
  247. InsertKbInt:
  248.    move.l   #$023900BF,D1
  249.  
  250. srch$
  251.    cmp.l (A0),D1
  252.    bne.b next$
  253.  
  254.    move.l   #$4E714EB9,(A0)+
  255.    GETUSRADDR  KbIntGame
  256.    move.l   D0,(A0)
  257.    rts         ; patch only once
  258.  
  259. next$
  260.    addq.l   #2,A0
  261.    cmp.l A0,A1
  262.    bne.b srch$
  263.    rts
  264.  
  265.    
  266. InsertBlitWaits:
  267.    move.l   #$3D440058,D1
  268.    move.l   #$3D460058,D2
  269.  
  270. srch$
  271.    cmp.l (A0),D1
  272.    bne   notblitd4$
  273.  
  274.    move.l   #$4E4E4E71,(A0)      ; trap $E
  275.    bra   next$
  276.  
  277. notblitd4$
  278.    cmp.l (A0),D2
  279.    bne   next$
  280.  
  281.    move.l   #$4E4F4E71,(A0)      ; trap $F
  282. next$
  283.    addq.l   #2,A0
  284.    cmp.l A0,A1
  285.    bne   srch$
  286.    rts
  287.  
  288. InsertBlitWaitsGame:
  289.    move.l   #$3D410058,D1
  290.    move.l   #$3D430058,D2
  291.  
  292. srch$
  293.    cmp.l (A0),D1
  294.    bne   notblitd1$
  295.  
  296.    move.l   #$4E4C4E71,(A0)      ; trap $C
  297.    bra   next$
  298.  
  299. notblitd1$
  300.    cmp.l (A0),D2
  301.    bne   next$
  302.  
  303.    move.l   #$4E4D4E71,(A0)      ; trap $D
  304. next$
  305.    addq.l   #2,A0
  306.    cmp.l A0,A1
  307.    bne   srch$
  308.    rts
  309.  
  310.  
  311.  
  312.  
  313. KbIntGame:
  314.    cmp.b #$5F,D0
  315.    bne   KbInt    ; no level skip
  316.    move.b   #1,$7F061
  317. KbInt:
  318.    and.b #$BF,$BFEE01
  319.    cmp.b #$59,D0
  320.    bne   noquit$
  321.    JSRGEN   InGameExit
  322. noquit$
  323.    RTS
  324.  
  325. ReadRoutine:
  326.    STORE_REGS
  327.    move.l   currdisk(pc),D0
  328.  
  329.    move.l   16(A5),D2      ; offset
  330.  
  331.    move.l   12(A5),D1      ; length
  332.    sub.l 8(A5),D1
  333.    move.l   8(A5),A0
  334.  
  335.    JSRGEN   ReadDiskPart
  336.  
  337.    move.l   12(A5),8(A5)
  338.  
  339.    RESTORE_REGS
  340.    rts
  341.  
  342. currdisk:
  343.    dc.l  0
  344.